package org.freetek.linkdn.util.scribe;

import static org.freetek.linkdn.util.communication.LinkedInConstants.LINKEDIN_API_KEY;
import static org.freetek.linkdn.util.communication.LinkedInConstants.LINKEDIN_SECRET_KEY;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.scribe.oauth.Scribe;

public abstract class ScribeUtil {

	private static final int SCRIBE_PROPS_COUNT = 8;

	private static Map<String, String> SCRIBE_PROPS;

	static {
		SCRIBE_PROPS = new HashMap<String, String>(SCRIBE_PROPS_COUNT);
		SCRIBE_PROPS.put("consumer.key", LINKEDIN_API_KEY);
		SCRIBE_PROPS.put("consumer.secret", LINKEDIN_SECRET_KEY);
		SCRIBE_PROPS.put("request.token.verb", "POST");
		SCRIBE_PROPS.put("request.token.url", "https://api.linkedin.com/uas/oauth/requestToken");
		SCRIBE_PROPS.put("access.token.verb", "POST");
		SCRIBE_PROPS.put("access.token.url", "https://api.linkedin.com/uas/oauth/accessToken");
		SCRIBE_PROPS.put("callback.url", "oob");
		SCRIBE_PROPS.put("scribe.equalizer", "org.scribe.eq.LinkedInEqualizer");
	}

	private static Properties getScribeProperties() {
		Properties result = new Properties();
		result.putAll(SCRIBE_PROPS);

		return result;
	}

	public static Scribe getScribeInstance() {
		return new Scribe(getScribeProperties());
	}
}
